/*******************************************************************************
 * Package: com.practice.security
 * Type:    UserDetail
 * Date:    2023/9/27 16:15
 *
 * Copyright (c) 2023 HUANENG GUICHENG TRUST CORP.,LTD All Rights Reserved.
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/
package com.practice.security;

import lombok.Getter;
import lombok.ToString;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;

/**
 * 登录时的信息
 * 登录时，会自动使用提交过来的用户名来调用UserDetailServiceImpl的`loadUserByUsername()`方法，
 * 并得到`UserDetails`类型的对象，此对象中包含用户的相关信息，例如密码、账号状态等，
 * 接下来表单提交过来的密码与`UserDetails`中的密码进行对比，且判断账号状态，决定此账号是否能够通过认证。
 *
 * @author Masiyu
 * @date 2023/9/27 16:15
 */
@ToString(callSuper = true)
public class UserDetail extends User {
    @Getter
    private Long id;
    @Getter
    private String state;
    
    public UserDetail(Long id,String username,String state, String password,boolean enabled, Collection<? extends GrantedAuthority> authorities) {
        super(username, password, enabled, true, true, true, authorities);
        this.id = id;
        this.state = state;
        
    }
}
